<?php

/**
 * 商品列表
 */

namespace app\shop\api;

class ListApi extends \dux\kernel\Api {

    /**
     * 获取关于我们
     */
    public function index() {


        $page = request('get', 'page', 1, 'intval');

        $orderUrl = request('get', 'order');

        $pageLimit = 10;

        $service = target('shop/List', 'service');

        $filterWhere = [];

        $data = $service->getData($filterWhere);

        $filter = $data['filter'];
        $where = $data['where'];

        $order = $data['order'];


        $offset = $pageLimit * ($page - 1);


        if($orderUrl == 'pos_id') {
            $order = 'A.pos_id asc' . ','. $order;
            $order = trim($order, ',');
        }


        $model = target('shop/Shop');
        if ($where) {
            $list = $model->loadList($where, [$offset, $pageLimit], $order);
        } else {
            $list = [];
        }

        if ($list) {
            $this->success([
                'data' => $list,
                'limit' => $page,
                'page' => $page,
            ]);
        } else {
            $this->error('暂无数据');
        }


    }

}